﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using ASPNETPerformance.App_BusinessLogic.Helpers;
using ASPNETPerformance.App_BusinessLogic.Utils;

namespace ASPNETPerformance.App_BusinessLogic.BasePages {
    public class BaseMasterPage : MasterPage {
        protected override void OnInit( EventArgs e ) {
            base.OnInit( e );
            SetFavIcon();
        }

        protected void SetFavIcon() {
            string favIconPath = HttpContext.Current.Request.PhysicalApplicationPath + "favicon.ico";
            if ( File.Exists( favIconPath ) ) {
                string favIconUrl = CommonHelper.GetDemosLocation() + "favicon.ico";

                HtmlLink htmlLink1 = new HtmlLink();
                htmlLink1.Attributes[ "rel" ] = "icon";
                htmlLink1.Attributes[ "href" ] = favIconUrl;

                HtmlLink htmlLink2 = new HtmlLink();
                htmlLink2.Attributes[ "rel" ] = "shortcut icon";
                htmlLink2.Attributes[ "href" ] = favIconUrl;

                Page.Header.Controls.Add( htmlLink1 );
                Page.Header.Controls.Add( htmlLink2 );
            }
        }
    }
}